-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: foldable chacha20 #51
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 8aa8b08.
lol the name here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes requested here. Mostly to not remove AES.
var tmp[4][32] = in; | ||
|
||
// a += b | ||
component add1 = AddBits(32); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like surely we can do this 32 bit add more efficiently, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I don't know, perhaps it's worth looking into if this circuits performance becomes a problem.
// counter => 32-bit word to apply w nonce | ||
signal input counter[32]; | ||
|
||
// the below can be both ciphertext or plaintext depending on the direction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite get this. Is this to say that the encryption algorithm is exactly the same as decryption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes thats exactly correct. this circuit is entirely symmetric.
// Test case from RCF https://www.rfc-editor.org/rfc/rfc7539.html#section-2.4.2 | ||
// the input encoding here is not the most intuitive. inputs are serialized as little endian. | ||
// i.e. "e4e7f110" is serialized as "10 f1 e7 e4". So the way i am reading in inputs is | ||
// to ensure that every 32 bit word is byte reversed before being turned into bits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -212,7 +206,7 @@ const json_key3_mask = [ | |||
const json_key3_mask_hash = DataHasher(json_key3_mask); | |||
|
|||
describe("NIVC_FULL", async () => { | |||
let aesCircuit: WitnessTester<["key", "iv", "aad", "ctr", "plainText", "cipherText", "step_in"], ["step_out"]>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of deleting a whole test case. We may want to come back to AES. We don't know yet, but I don't want to remove this circuit and its test in this PR.
In general, PRs should do one thing -- this one adds fodlable ChaCha20. It should not remove AES-GCTR. This is the main reason this got reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what should we use in the full test AES or ChaCha?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually just put them both back in the full test for now which seems best.
signal input in[BITS]; | ||
signal output out[BITS]; | ||
for (var i = 0; i < BITS; i++) { | ||
out[i] <== in[(i + L) % BITS]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modular arithmetic is the best thing
Reverts #50
This one is reopen so now you can review